package o;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView.s;
import com.huawei.appgallery.foundation.card.base.bean.KeywordInfo;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSView;
import com.huawei.appmarket.service.interactive.bean.InteractiveRecommItemCardBean;
import huawei.widget.HwButton;
import java.util.LinkedHashMap;
import java.util.List;
import o.ewm.h;
import o.ewm.j;

public class ebj extends androidx.recyclerview.widget.RecyclerView.a implements OnClickListener {
    private String ˊ;
    private List<InteractiveRecommItemCardBean> ˋ;
    private int ˎ;
    private CSSRule ˏ;

    class a extends s {
        private HwButton ॱˋ;
        final /* synthetic */ ebj ᐝॱ;

        private a(ebj o_ebj, View view) {
            this.ᐝॱ = o_ebj;
            super(view);
            this.ॱˋ = (HwButton) view.findViewById(j.ͺˌ);
        }
    }

    public void ˎ(List<InteractiveRecommItemCardBean> list, String str) {
        this.ˋ = list;
        this.ˊ = str;
        ˊ();
    }

    public void ˏ(CSSRule cSSRule) {
        this.ˏ = cSSRule;
    }

    @NonNull
    public s ˎ(@NonNull ViewGroup viewGroup, int i) {
        View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(h.ॱי, viewGroup, false);
        if (MinimumFactory.getBoolValue(ContentManager.getInstant().getContext())) {
            inflate.setLayoutDirection(1);
        }
        s aVar = new a(inflate);
        if (this.ˏ != null) {
            CSSView.wrap(inflate, this.ˏ).render();
        }
        this.ˎ = dgm.ˎ((Activity) inflate.getContext());
        return aVar;
    }

    public void ॱ(@NonNull s sVar, int i) {
        if (sVar instanceof a) {
            ˊ(((a) sVar).ॱˋ, i);
        }
    }

    public int ˏ() {
        if (CollectCheck.isEmpty(this.ˋ)) {
            return 0;
        }
        return this.ˋ.size();
    }

    private void ˊ(Context context, InteractiveRecommItemCardBean interactiveRecommItemCardBean) {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("detailId", interactiveRecommItemCardBean.ॱॱ());
        linkedHashMap.put("keyword", interactiveRecommItemCardBean.ˊ());
        linkedHashMap.put("serviceType", String.valueOf(this.ˎ));
        dgh.ˋ("370101", linkedHashMap);
        dyk.ॱ(context, this.ˊ, interactiveRecommItemCardBean.ॱॱ());
    }

    public void onClick(View view) {
        if (!CollectCheck.isEmpty(this.ˋ)) {
            Context context = view.getContext();
            InteractiveRecommItemCardBean interactiveRecommItemCardBean = (InteractiveRecommItemCardBean) this.ˋ.get(((Integer) view.getTag()).intValue());
            if (interactiveRecommItemCardBean != null) {
                ˊ(context, interactiveRecommItemCardBean);
                if (interactiveRecommItemCardBean.ॱ() == 1) {
                    KeywordInfo keywordInfo = new KeywordInfo();
                    keywordInfo.ॱ(ˏ(interactiveRecommItemCardBean.ॱॱ()));
                    keywordInfo.ˎ(interactiveRecommItemCardBean.ˊ());
                    ety.ˊ().ॱ(view.getContext(), null, false, true, keywordInfo);
                } else if (interactiveRecommItemCardBean.ॱ() == 2 && !cii.ˊ().ˊ(context, interactiveRecommItemCardBean)) {
                    cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
                    appDetailActivityProtocol.ˏ(new Request(interactiveRecommItemCardBean.ॱॱ(), null));
                    cjk.ˎ().ˋ(context, new cjm("appdetail.activity", appDetailActivityProtocol));
                }
            }
        }
    }

    private String ˏ(String str) {
        return (TextUtils.isEmpty(str) || !str.startsWith("searchApp|")) ? str : str.substring("searchApp|".length());
    }

    private void ˊ(HwButton hwButton, int i) {
        if (hwButton == null || i < 0 || i >= ˏ()) {
            Logger.ˋ("RecommendCardAdapter", "itemView or position is invalid.");
            return;
        }
        hwButton.setText(((InteractiveRecommItemCardBean) this.ˋ.get(i)).ˊ());
        hwButton.setTag(Integer.valueOf(i));
        hwButton.setOnClickListener(new ckt(this));
    }
}
